package Test;

import java.io.*;
import java.util.Scanner;

public class t1 {

    static int[] grade;
    static int[][] graph;
    static final int INFINITY = 1 << 16;

    static int n;
    static int m;
    static int start;
    static int end;

    static int[] dist;
    static int[] g_dist;
    static boolean[] visit;

    public void dijkstra() {

        //将start点加入两个dist数组
        dist[start] = 0;
        g_dist[start] = grade[start];
        visit[start] = true;

        //dijkstra算法
        for (int j = 0; j < n; j++) {

            //求出dist数组中的最小值，将下标给u
            int min = INFINITY;
            int u = 0;
            for (int i = 0; i < n; i++) {
                if (!visit[i] && dist[i] < min) {
                    min = dist[i];
                    u = i;
                }
            }
            //u点已经被访问
            visit[u] = true;
            /*
                更新两个dist数组
             */
            for (int i = 0; i < n; i++) {
                if (!visit[i] && dist[u] != INFINITY && graph[u][i] != 0)
                    if (dist[u] + graph[u][i] < dist[i]) {
                        // 如果花费的时间短，直接更新
                        dist[i] = dist[u] + graph[u][i];
                        g_dist[i] = g_dist[u] + grade[i];
                    } else if (dist[u] + graph[u][i] == dist[i] && g_dist[u] + grade[i] > g_dist[i]) {
                        //如果花费的时间相同，取分数最大
                        g_dist[i] = g_dist[u] + grade[i];
                    }
            }
        }
    }

    public void createGraph() {
        Scanner cin = new Scanner(System.in);

        //基本数据
        n = cin.nextInt();
        m = cin.nextInt();
        start = cin.nextInt();
        end = cin.nextInt();

        //分数
        grade = new int[n];
        for (int i = 0; i < n; i++) {
            grade[i] = cin.nextInt();
        }
        //带权无向图
        graph = new int[n][n];
        for (int i = 0; i < m; i++) {
            int a = cin.nextInt();
            int b = cin.nextInt();
            int c = cin.nextInt();
            graph[a][b] = graph[b][a] = c;
        }

        //dist数组
        dist = new int[n];
        g_dist = new int[n];
        visit = new boolean[n];
        for (int i = 0; i < n; i++) {
            if (graph[start][i] != 0) {
                dist[i] = graph[start][i];
                g_dist[i] = grade[start] + grade[i];
            } else {
                dist[i] = INFINITY;
            }
        }
    }

    public void printReasult() {
        System.out.print(dist[end] + " " + g_dist[end]);
    }

    public static void main(String[] args) throws IOException {

        t1 t = new t1();
        t.createGraph();
        t.dijkstra();
        t.printReasult();
    }

}